package sch.jl.caigou.impl;

import java.util.ArrayList;
import java.util.List;

import jiliang.purchase.demo.think_UpDateShenhe;
import sch.jl.caigou.dao.think_UpDateshenheDao;

public class think_UpDateshenheImpl extends DaoImpl<think_UpDateShenhe> implements think_UpDateshenheDao
{
	private List<String> bz_id = new ArrayList<String>();
	private List<String> bz_mc = new ArrayList<String>();
	private List<String> lc_id = new ArrayList<String>();
	

	public void updateShenhe(think_UpDateShenhe tuds,String shenqingsj) {
		// TODO Auto-generated method stub
		inint();
		String lc ="";
		int sign = 0;
		for(int i=0;i<bz_mc.size();i++)
		{
			if(tuds.getBz_id().equals(bz_mc.get(i)))
			{
				lc = lc_id.get(i);
				sign = i;
				break;
			}
		}
		String shenqing_sql="";
		String shenhe_sql = "";
		if(tuds.getSh_zhuangtai().equals("2"))
		{
			
			if(tuds.getBz_id().equals("计财处审核"))
			{
				shenqing_sql = "update think_shenqing set last_lc='"+tuds.getBz_id()+"通过',lc_id='"+lc+"',states='"+3+"' where sq_id='"+tuds.getSq_id()+"'";
				//shenhe_sql = "insert into think_shenhe(sq_id,bz_id,sh_zhuangtai,sh_ren,sh_riqi,sh_yijian) values('"+tuds.getSq_id()+"','"+(sign+1)+"','','2','"+tuds.getSh_riqi()+"','"+tuds.getSh_yijian()+"');";
			}
			else
			{
				shenqing_sql = "update think_shenqing set last_lc='"+tuds.getBz_id()+"通过',lc_id='"+lc+"',states='"+1+"' where sq_id='"+tuds.getSq_id()+"'";
			}
			shenhe_sql = "insert into think_shenhe(sq_id,bz_id,sh_zhuangtai,sh_ren,sh_riqi,sh_yijian) values('"+tuds.getSq_id()+"','"+(bz_id.get(sign))+"','2','"+tuds.getSh_ren()+"','"+tuds.getSh_riqi()+"','"+tuds.getSh_yijian()+"')";
		}
		else
		{
			shenqing_sql = "update think_shenqing set last_lc='"+tuds.getBz_id()+"不通过',lc_id='"+lc+"',states='"+5+"' where sq_id='"+tuds.getSq_id()+"'";
			shenhe_sql = "insert into think_shenhe(sq_id,bz_id,sh_zhuangtai,sh_ren,sh_riqi,sh_yijian) values('"+tuds.getSq_id()+"','"+(bz_id.get(sign))+"','2','"+tuds.getSh_ren()+"','"+tuds.getSh_riqi()+"','"+tuds.getSh_yijian()+"')";
		}
		
		update(shenqing_sql);
		insert(shenhe_sql);
		if(tuds.getBz_id().equals("实验处审核"))
		{
			String bei_z = "update think_lingxing_sbjj set shenqingsj =? where sq_id=?";
			update(bei_z,shenqingsj,tuds.getSq_id());
		}
	}
	
	public void inint()
	{
		bz_id.add("8");
		bz_id.add("3");
		bz_id.add("10");
		bz_id.add("15");
		bz_id.add("20");
		
		bz_mc.add("经费负责人审核");
		bz_mc.add("实验处审核");
		bz_mc.add("采购中心审核");
		bz_mc.add("计财处审核");
		bz_mc.add("完成");
		
		lc_id.add("23");
		lc_id.add("24");
		lc_id.add("25");
		lc_id.add("26");
	}

}
